Traditional video codecs include some in-loop filtering processes for improving the quality of reconstructed images.
One state-of-the-art in-loop filter, complying with HEVC, is the Sample Adaptive Offset (SAO), described in section 8.7.3 of the document ITU-T H.265 entitled “High Efficiency Video Coding”. Such offset filter allows adding offsets to some pixels in order to reduce coding artifacts. Two types of filters may be used when SAO is enabled (or activated): Edge Offset (EO) filter or Band Offset (BO) filter. Only one type of SAO filter may be selected for a CTB and the whole CTB is then filtered by either EO filter or BO filter. When the color format include chroma components, the SAO mode is the same for Cb and Cr components. In case of EO or BO, one set of SAO parameters per channel component (e.g. Y,U,V) is encoded, possibly shared with neighboring CTUs (when SAO merge flag is enabled).
As illustrated in FIG. 1, when EO filter is applied, pixels are classified based on edge direction and shape, and corresponding offset value are added to each pixel. First, one of four edge directions is selected for a current pixel and its neighbors (EO—0°, EO—90°, EO—135°, and EO—45°. For the selected direction, a category is assigned to the pixel, depending on the local gradients. Five categories are determined according to HEVC:                category 0—flat area,        category 1—local minimum,        category 2—edge (positive offset),        category 3—edge (negative offset),        category 4—local maximum        
EdgelxConditionMeaning0p = n0 and p = n1flat area1p < n0 and p < n1local minimum2p < n0 and p = n1, or p <edgen1 and p = n03p > n0 and p = n1 or p >edgen1 and p = n04p > n0 and p > n1local maximum
Offsets for each of categories 1-4 are computed after the pixels are classified and encoded in a stream.
As illustrated in FIG. 2, when BO filter is applied, the pixel value range (0 . . . 255, in 8-bit) is divided into 32 bands (b0, b1, b31) and the pixels belonging to four consecutive bands (b11, b12, b13, b14) starting from a starting band position are modified by adding an offset value (one for each of the consecutive four bands) that is encoded in the stream. It could be considered that the pixels belonging to the four consecutive bands (b11, b12, b13, b14) are assigned to categories 1-4, for which an offset value is computed and encoded, and the pixels belonging to the other bands (b0, b10, b15, b31) are assigned to category 0.
The starting band position and the four offset values are thus encoded in the stream.
As already mentioned, SAO is used to reduce coding artifacts, e.g. ringing artifacts. Ringing artifact is a typical video coding artifact that may appear near sharp edges and that is more visible on nearly uniform (flat) areas. EO aims at reducing ringing artifacts but tends to modify textured areas too, whereas BO does not remove ringing artifacts but corrects the banding artifacts.
It would hence be desirable to provide a technique for encoding and/or decoding an image or a sequence of images aiming at reducing coding artifacts more efficiently.